package com.line.model.entity;

import org.springframework.format.annotation.DateTimeFormat;
import org.hibernate.annotations.DynamicInsert;

import javax.persistence.GeneratedValue;
import javax.persistence.Column;
import javax.persistence.GenerationType;
import java.util.Date;

import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Entity;


import javax.persistence.Id;

/**
 * <p>
 * OAuth2授权账户表，采用OAuth2授权，通过token进行访问，表采用二级子父结构，可接入多个平台，每个平台可分配多个客户端授权帐号与密码授权帐号。
 * </p>
 *
 * @author Focus
 * @version 1.0
 * @since 2018-09-04
 */
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "auth_app")
public class AuthAppEntity implements java.io.Serializable {

    private static final long serialVersionUID = -1L;

    /**
     * 主键id，自增长；
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false, unique = true, length = 20)
    private Long id;

    /**
     * 创建时间，仅用于维护；
     */
    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Column(name = "gmt_create", nullable = false)
    private Date gmtCreate;

    /**
     * 更新时间，仅用于维护；
     */
    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Column(name = "gmt_update", nullable = false)
    private Date gmtUpdate;

    /**
     * 帐号ID，用于获取token时的唯一标识，由IL开头，后面采用20位随机字符串
     */
    @Column(name = "appid", length = 32)
    private String appid;

    /**
     * 帐号密码，用于获取token时使用。
     */
    @Column(name = "secret", length = 64)
    private String secret;

    @Column(name = "access_token_expires")
    private Integer accessTokenExpires;

    @Column(name = "refresh_token_expires")
    private Integer refreshTokenExpires;


    @Column(name = "name", length = 64)
    private String name;

    @Column(name = "ip_white")
    private String ipWhite;


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getGmtCreate() {
        return gmtCreate;
    }

    public void setGmtCreate(Date gmtCreate) {
        this.gmtCreate = gmtCreate;
    }

    public Date getGmtUpdate() {
        return gmtUpdate;
    }

    public void setGmtUpdate(Date gmtUpdate) {
        this.gmtUpdate = gmtUpdate;
    }

    public String getAppid() {
        return appid;
    }

    public void setAppid(String appid) {
        this.appid = appid;
    }

    public String getSecret() {
        return secret;
    }

    public void setSecret(String secret) {
        this.secret = secret;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAccessTokenExpires() {
        return accessTokenExpires;
    }

    public void setAccessTokenExpires(Integer accessTokenExpires) {
        this.accessTokenExpires = accessTokenExpires;
    }

    public Integer getRefreshTokenExpires() {
        return refreshTokenExpires;
    }

    public void setRefreshTokenExpires(Integer refreshTokenExpires) {
        this.refreshTokenExpires = refreshTokenExpires;
    }

    public String getIpWhite() {
        return ipWhite;
    }

    public void setIpWhite(String ipWhite) {
        this.ipWhite = ipWhite;
    }
}
